home *** CD-ROM | disk | FTP | other *** search
-
- NAME EPSONRX
- PAGE 50,130
- TITLE EPSONRX.COM RITARI/MACK '87
- ;
- ;******************************************************************************
- ;
- ;EPSONRX.COM -Setup Utility for Epson printer
- ; from an idea by Douglas Ritari; PC Tech J., Sep 84, p 79
- ;
- ; Modified by Joseph MACK
- ; Dept Chemistry, UMBC
- ; 5401 Wilkens Ave
- ; Catonsville,MD,21228
- ; (301)-455-3292
- ; Jun '87
- ;
- ;******************************************************************************
- ;
- ;prog constants
- cr equ 13
- lf equ 10
- ;
- ;
- MAIN SEGMENT PARA PUBLIC 'CODE'
- ORG 100H
-
- START PROC FAR
- ;
- ASSUME CS:MAIN
- ASSUME DS:MAIN
- ASSUME SS:MAIN
- ASSUME ES:MAIN
- db "EPSONRX.COM Joe MACK Jun 87" ;Notice in early code
- ;PUBLICS------------------------------------------------
- ;numbers
- public sw,testpr,num_digits,fd_oor,parm
- ;procedures
- public sstart, start, alpha_entry, buzzer, default, disp_char, escape, hex_err_msg, hexmath, hexon, printer, prmsg,
- ;general locations
- public alph_hex, bit_3_ok, bit_5_ok, b_loop, end_math, end_parm, hex_ok, math2, out_test, out_of_range, second_digit, search, search_end, slash, success, sw_on
- ;parms
- public parm_a, parm_b, parm_c, parm_d, parm_e, parm_f, parm_g, parm_h, parm_i, parm_j, parm_k, parm_l, parm_m, parm_n, parm_o, parm_p, parm_q, parm_r, parm_s, parm_t, parm_u, parm_v, parm_w, parm_x
- ;errors
- public error_3, error_4, error_5, prn_err_bit_3, prn_err_bit_5
- ;msgs
- public success_msg, prog_name, d_msg, inkey_msg, err_msg_1, err_msg_2, err_msg_3, err_msg_4, err_msg_5, err_msg_6, err_msg_8
- ;
- ;--------------------------------------------
- ;
- JMP SSTART ;Jump to real start of prog
- ;
- ;************************INITIALISE DATA VARIABLES*****************************
- ;constants initialised at load time, not at execution time
- ;
- SW DB 0 ;Switch for HEX '/' seq.-either '0' or 'FFH'
- SIXTEEN DB 16 ;the number '16' used in hex conversion -mul
- TESTPR DB 0 ;Switch to test if any output was produced
- NUM_DIGITS DB 0 ;Number of hex digits produced-'0' or '1'
- FD_OOR DB 0 ;first digit out of range
- HEX DB 0 ;hex accumulator
- PARM DB 0 ;Move param to here -1 byte at a time
- ;
- ;******************************************************************************
- ; BEGIN PROG- SAVE RETURN ADDRESS FOR DOS
- ;******************************************************************************
- ;
- SSTART:
- PUSH DS ;Save PSP Seg address
- MOV AX,0
- PUSH AX ;Save return address offset (PSP+0)
- ;
- ;***************CHECK PRINTER***************************************************
- ;
- PUSH AX
- PUSH DX ;save registers
- MOV AH,02 ;read port
- MOV DX,0 ;port 00=printer#1
- INT 17H ;read status
- TEST AH,8H ;bit 3 on?-I/O error
- JZ BIT_3_OK
- LEA DX,prn_err_bit_3
- CALL PRMSG
- POP DX
- POP AX
- RET ;pop registers and exit to DOS
- BIT_3_OK:TEST AH,20H ;bit 5 on?-out of paper
- JZ BIT_5_OK
- LEA DX,prn_err_bit_5
- CALL PRMSG
- POP DX
- POP AX
- RET ;exit to DOS
- BIT_5_OK:POP DX
- POP AX
- ;
- ;got here if printer OK
- ;
- ;******************MOVE COUNT OF CHARACTERS INTO PARM AREA********************
- ;
- MOV SI,80H ;Source string offset (within PSP)
- MOV DI,OFFSET PARM ;dest string offset
- CLD ;Set 'forward' string operations
- MOVSB ;move # of params entered into 'PARM' variable
- DEC DI
- ;
- ;*******************SET UP PARM FIELD'S POINTERS*******************************
- ;
- MOV AL,PARM ;Put number of char. in parm into AL register
- MOV CX,AX ; " CX
- MOV BX,OFFSET PARM ;point to parms base address
- CMP CX,0 ;were no parms entered ?
- JNE SEARCH ;param found
- CALL DEFAULT ;end of search, no parms found-send defaults
- RET ;end program, return to DOS,(PSP and offset POPed)
- ;
- ;******************************************************************************
- ; PARMS WERE ENTERED- SEARCH FOR AND PROCESS PARAMETERS
- ;******************************************************************************
- ;
- SEARCH: MOVSB ;read in parm from prog.seg. prefix
- DEC DI
- MOV AL,[BX] ;move next parm to input reg
- CMP AL,' ' ;blank?
- JE SEARCH_END ;ignore
- CMP AL,',' ;comma?
- JE SEARCH_END ;ignore
- ;
- CMP AL,'a' ;UC/lc?
- JL ALPH_HEX ;do not modify this letter if lower than 'a'
- AND AL,223 ;reduce by 32, uncaps==>caps
- ;
- ALPH_HEX:CMP SW,0 ;=1 hex sequence on,=0 off
- JE SLASH ;expects alph input
- CALL HEXON ;expects hex input
- JMP SEARCH_END
- ;
- ;got here if hex not on
- ;
- SLASH: CMP AL,'/' ;hex sequence begun?
- JE SW_ON
- CALL ALPHA_ENTRY ;expects alphabetic input
- JMP SEARCH_END ;look for next char
- ;
- SW_ON: MOV SW,1 ;turn on hex sequence
- SEARCH_END: LOOP SEARCH ;get more input
- ;
- ;******************************************************************************
- ;Get here if no more parms available. Check for unpaired hex digits
- ;******************************************************************************
- ;
- CMP NUM_DIGITS,0 ;unpaired hexcodes? =0 paired, =1 unpaired?
- JE OUT_TEST
- PUSH DX
- LEA DX,err_msg_6 ;unpaired digits
- CALL PRMSG
- POP DX
- ;
- CALL DISP_CHAR ;ouput unpaired digit
- ;
- OUT_TEST: CMP TESTPR,1 ;=0 no valid output
- JE SUCCESS
- CALL DEFAULT
- ;
- SUCCESS: PUSH DX
- LEA DX,success_msg
- CALL PRMSG
- POP DX
- ;
- RET ; to DOS
- ;
- ;*************End of prog proc*************************************************
- ;
- START ENDP ;end main
- ;
- ;******************************************************************************
- ;
- ; ORG 200H
- ;
- PRMSG PROC NEAR
- ;int 21h scrambles AX, I didn't expect that, so save AX
- PUSH AX
- MOV AH,9 ;print string instruction
- INT 21H ;print DX msg
- POP AX
- RET
- PRMSG ENDP
- ;
- ;*************Escape routine, send escape code to printer**********************
- ;
- ESCAPE PROC NEAR
- PUSH AX ;save potential char to be printed on stack
- MOV AL,1BH ;escape char to out reg.
- CALL PRINTER
- POP AX
- CALL PRINTER ;send saved char
- RET
- ESCAPE ENDP
- ;
- ;*************printing s/r- all done from here**********************************
- ;
- ;send char in AL to printer
- ;
- PRINTER PROC NEAR
- MOV TESTPR,1 ;valid output has been produced
- MOV DX,0 ;set register for printer output INT
- MOV AH,0 ;"
- INT 17H ;call printer driver in BIOS
- RET
- PRINTER ENDP
- ;
- ;*************Edit for valid hex numbers ***************************************
- ;
- HEXON PROC NEAR ;tests for valid hex digit,
- ;if OK calls HEXMATH, otherwise sends errors
- SUB AL,30H ;convert from ASCII to rel numbers (30H=0D)
- JC OUT_OF_RANGE ;carry flag set, char<30H=0D, invalid param
- CMP AL,9 ;check for digit >9
- JBE HEX_OK ;valid number, jump to math routine call
- SUB AL,7 ;convert from ASCII to hex A-F
- CMP AL,0FH
- JA OUT_OF_RANGE ;error if hex>0FH
- ;
- HEX_OK: CALL HEXMATH ;convert input param to hex
- RET ;to main
- ;
- ;Get here if hex parm not in range 0-0FH
- ;
- OUT_OF_RANGE: CMP NUM_DIGITS,0 ;=0 if first digit
- JNE SECOND_DIGIT
- INC NUM_DIGITS
- MOV FD_OOR,1 ;first digit out of range
- CALL HEX_ERR_MSG
- RET
- ;
- SECOND_DIGIT:
- CALL HEX_ERR_MSG
- MOV SW,0 ;reset switches
- MOV NUM_DIGITS,0
- MOV FD_OOR,0
- RET
- ;
- HEXON ENDP
- ;
- ;********convert input params to hex numbers*********************************************************************
- ;
- HEXMATH PROC NEAR
- CMP NUM_DIGITS,0 ;0= 1st ,1= 2nd number
- JNE MATH2 ;jump and process second number
- MUL SIXTEEN ;mult 1st number by 16
- MOV HEX,AL ;clear & restore result in hex
- INC NUM_DIGITS ;1st number processed
- RET
- ;
- MATH2: CMP FD_OOR,1 ;0= valid
- JE END_MATH
- ADD AL,HEX ;second hex number, total the two digits
- MOV NUM_DIGITS,0 ;clear digit var for further use
- CALL PRINTER ;send hex number in AL to printer
- ;
- END_MATH:MOV FD_OOR,0 ;reset switches
- MOV SW,0
- RET
- ;
- HEXMATH ENDP
- ;
- ;********hex error messages****************************************************
- ;
- HEX_ERR_MSG PROC NEAR
- ;
- PUSH AX ;int 21h scrambles AL
- PUSH DX
- LEA DX,err_msg_1 ;invalid hex param
- CALL PRMSG
- POP DX
- POP AX
- ;
- CALL DISP_CHAR ;output orig invalid char
- ;
- PUSH DX
- LEA DX,err_msg_4 ;parm ignored, execution continued
- CALL PRMSG
- POP DX
- ;
- RET
- ;
- HEX_ERR_MSG ENDP
- ;
- ;******************************************************************************
- ;
- DISP_CHAR PROC NEAR
- ;
- MOV AL,[BX] ;recover orig char
- PUSH BX ;save registers before outputting char
- PUSH CX
- XOR BX,BX ;clear BX, sets page to 0
- MOV CX,1 ;1 char to display
- MOV AH,0AH ;int fn 10D
- INT 10H ;display char at cursor posn
- POP CX
- POP BX
- ;
- RET
- ;
- DISP_CHAR ENDP
- ;
- ;******************************************************************************
- ;
- ;*************BUZZER s/r*******************************************************
- ;sounds buzzer
- ;
- BUZZER PROC NEAR
- MOV AL,07 ;buzzer param
- CALL PRINTER
- RET
- BUZZER ENDP
- ;
- ;*************DEFAULT S/R*******************************************************
- ;
- ;changes TESTPR to 1 through call to PRINTER, so PGMEND detects successfull output
- ;No params found, set default,
- ;
- ;*******************************************************************************
- ;
- ; ORG 300H
- ;
- DEFAULT PROC NEAR
- ;
- MOV AL,07H ;beep
- CALL PRINTER
- ;
- ; CALL PRINTER
- ;
- ;******************************************************************************
- ;If no param codes entered then give param codes.
- ;Notify of default execution and type.
- ;Defaults are set before displaying message.
- ;If print echoed, will see default font on printer.
- ;******************************************************************************
- ;
- PUSH DX ;save DX
- ; LEA DX,prog_name ;prog name
- ; CALL PRMSG ;print message
- LEA DX,d_msg ;default params send to screen
- CALL PRMSG
- ;
- LEA DX,inkey_msg ;msg for "inkey to continue"
- CALL PRMSG
- POP DX
- ;
- MOV AH,0 ;wait for key press
- INT 16H ;call keyboard_io at F000:E82E, wait for char
- POP AX ;ignore char in AL
- ;
- PUSH DX
- LEA DX,p_msg ;param codes available send to screen
- CALL PRMSG
- POP DX ;recover DX
- ;
- RET
- DEFAULT ENDP
- ;
- ;******************************************************************************
- ;PARAMETER DECISION AND ACTION
- ;******************************************************************************
- ;
- ; ORG 400H
- ;
- ALPHA_ENTRY PROC NEAR
- ;
- PARM_A:
- PARM_B: CMP AL,'B' ;buzzer?
- JNE PARM_C
- MOV AL,07H
- ;do loop
- PUSH CX ;currently being used for number of parms
- MOV CX,04H
- B_LOOP: CALL PRINTER ;need long beep
- LOOP B_LOOP
- POP CX
- JMP END_PARM
- ;
- PARM_C: CMP AL,'C' ;condense?
- JNE PARM_D
- MOV AL,0FH
- CALL PRINTER ;condensed doesn't need escape
- JMP END_PARM
- ;
- PARM_D: CMP AL,'D' ;double strike?
- JNE PARM_E
- MOV AL,'G'
- CALL ESCAPE
- JMP END_PARM
- ;
- PARM_E: CMP AL,'E' ;elite? 12/"
- JNE PARM_F
- MOV AL,'M' ;elite (12/")
- CALL ESCAPE
- JMP END_PARM
- ;
- PARM_F: CMP AL,'F' ;form feed?
- JNE PARM_G
- MOV AL,0CH ;advance paper to top of form
- CALL PRINTER
- JMP END_PARM
- ;
- PARM_G:
- PARM_H:
- PARM_I: CMP AL,'I' ;italics
- JNE PARM_J
- MOV AL,'4'
- CALL ESCAPE
- JMP END_PARM
-
- PARM_J:
- PARM_K:
- PARM_L: CMP AL,'L' ;line feed
- JNE PARM_M
- MOV AL,0AH
- CALL PRINTER
- JMP END_PARM
- ;
- PARM_M: CMP AL,'M' ;parm to 'eMphasise'?
- JNE PARM_N
- MOV AL,45H ;Epson code for eMphasised font
- CALL ESCAPE
- JMP END_PARM
- ;
- PARM_N:
- PARM_O:
- PARM_P: CMP AL,'P' ;Pica- if do reset get new TOF
- JNE PARM_Q ;instead turn of all print width functions
- MOV AL,'P' ;elite off
- CALL ESCAPE
- MOV AL,18H ;compressed off
- CALL PRINTER
- MOV AL,'W' ;wide off
- CALL ESCAPE
- MOV AL,00H ;off
- CALL PRINTER
- JMP END_PARM
- ;
- PARM_Q:
- PARM_R: CMP AL,'R' ;reset?
- JNE PARM_S
- MOV AL,'@' ;reset= cancell all modes, reset to logical TOF
- CALL ESCAPE ;pica =10 char per inch
- JMP END_PARM
- ;
- PARM_S:
- PARM_T: CMP AL,'T' ;set tabs?
- JNE PARM_U
- MOV AL,'e'
- CALL ESCAPE
- MOV AL,05H ;tabs at repeats of 5
- CALL PRINTER
- JMP END_PARM
- ;
- PARM_U: CMP AL,'U' ;underline
- JNE PARM_V
- MOV AL,'-'
- CALL ESCAPE
- MOV AL,01H ;set "on"
- CALL PRINTER
- JMP END_PARM
- ;
- PARM_V:
- PARM_W: CMP AL,'W' ;wide
- JNE PARM_X
- MOV AL,'W'
- CALL ESCAPE
- MOV AL,01H ;set "on"
- CALL PRINTER
- JMP END_PARM
- ;
- PARM_X:
- PARM_Y:
- PARM_Z: JMP ERROR_3
- END_PARM: RET ;exit s/r
- ;
- ;Invalid alphabetical parameter found
- ;
- ERROR_3: PUSH DX ;write error message
- LEA DX,err_msg_3 ;invalid parm msg
- CALL PRMSG
- POP DX
- ;
- CALL DISP_CHAR
- ;
- ERROR_4: PUSH DX
- LEA DX,err_msg_4 ;parm ignored, execution continued
- CALL PRMSG
- ERROR_5: LEA DX,err_msg_5 ;where to find valid parm list
- CALL PRMSG
- POP DX
- RET ;to main,
- ;
- ALPHA_ENTRY ENDP
- ;
- ;******************************************************************************
- ;Program data
- ;
- ;
- ; ORG 600H
- ;
- ;
- p_msg db "Command Format:-Epson [/xx] [a][b]",cr,lf,lf
- db "/xx -heX input (must be paired) ",cr,lf
- db " ***************************",cr,lf
- db "B -Buzzer on printer * Conflict Priorities *",cr,lf
- db "C -Condensed * *",cr,lf
- db "D -Double Strike * Elite *",cr,lf
- db "E -Elite 12/inch * \ *",cr,lf
- db "F -Form feed * Emphasised *",cr,lf
- db "I -Italic * \ *",cr,lf
- db "L -Line feed * Compressed *",cr,lf
- db "M -eMphasized * \ *",cr,lf
- db "P -Pica, 12/inch * Pica *",cr,lf
- db "R -Reset = clear, TOF, Pica, ***************************",cr,lf
- db "T -Tabs at mulitiple of 5 ",cr,lf
- db "U -Underline ",cr,lf
- db "W -Wide ",cr,lf
- db "/ -Hex on for 2 chars. Blanks, commas ignored on command line. ",cr,lf
- db "UC or lc or mixed are OK. Hex and alphabetical mixed is OK. ",cr,lf
- db "Some commands will undo previous commands. ",cr,lf,"$"
- ;
- ;******************************************************************************
- ;
- success_msg db cr,lf
- db "EPSONRX.COM Ritari/Mack 1987",cr,lf,"$"
- ;
- prog_name db cr,lf
- db "EPSONRX.COM written by Douglas Ritari, 1983",cr,lf
- db " modified by Joseph Mack , 1987",cr,lf,lf,"$"
- ;
- d_msg db cr,lf
- db "These current default codes have been sent to the printer:",,
- ;
- ;put command(s) parameters, for current default, into next line, between double quotes
- ;
- db "B"
- db cr,lf,lf,"$"
- ;
- inkey_msg db cr,lf,"Press any key to continue." ,cr,lf,"$"
- err_msg_1 db cr,lf,"Invalid hex digit found(ie not 0-0FH):$" ,
- err_msg_2 db cr,lf,"No action taken.",cr,lf ,"$"
- err_msg_3 db cr,lf,"Invalid alphabetical character:$" ,
- err_msg_4 db cr,lf,"Character ignored, execution continued.$"
- err_msg_5 db cr,lf,"Valid parameters available by returning to DOS and typing <EPSONRX>.",cr,lf,"$"
- err_msg_6 db cr,lf,"Unpaired hex parameter:$" ,
- err_msg_8 db cr,lf,"Character ignored, execution terminated." ,cr,lf,"$"
- prn_err_bit_3 db cr,lf,"printer I/O error." ,cr,lf,"$"
- prn_err_bit_5 db cr,lf,"printer out of paper." ,cr,lf,"$"
- ;
- ;******************************************************************************
- ;
- ;
- MAIN ENDS
- END START